package org.xue.snowmall.authserver.controller;

import java.util.Arrays;
import java.util.Map;
import org.xue.snowmall.common.utils.R;

import entity.UserRecordEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import org.xue.snowmall.authserver.service.UserRecordService;
import org.xue.snowmall.common.utils.PageUtils;


/**
 * 
 *
 * @author zy
 * @email 2067065884@qq.com
 * @date 2021-09-19 09:47:52
 */
@RestController
@RequestMapping("authserver/userrecord")
public class UserRecordController {
    @Autowired
    private UserRecordService userRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{usmId}")
    public R info(@PathVariable("usmId") Long usmId){
		UserRecordEntity userRecord = userRecordService.getById(usmId);

        return R.ok().put("userRecord", userRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody UserRecordEntity userRecord){
		userRecordService.save(userRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserRecordEntity userRecord){
		userRecordService.updateById(userRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] usmIds){
		userRecordService.removeByIds(Arrays.asList(usmIds));

        return R.ok();
    }

}
